import syscall

fn main():void! {
    var s = syscall.stat('./asserts/stat.txt')
    println(s.dev)
    println(s.ino)
    println(s.nlink)
    println(s.rdev)
    println(s.size)
    println(s.blksize)
    println(s.blocks)
    println(s.mode) // v
    println(s.uid)
    println(s.gid)
    println(s.atim.sec)
    println(s.atim.nsec)
    println(s.mtim.sec)
    println(s.mtim.nsec)
    println(s.ctim.sec)
    println(s.ctim.nsec)


    var fd = syscall.open('./asserts/stat.txt', syscall.O_RDONLY, 0666)
    var s2 = syscall.fstat(fd)
    syscall.close(fd)

    println(s2.dev)
    println(s2.ino)
    println(s2.nlink)
    println(s2.rdev)
    println(s2.size)
    println(s2.blksize)
    println(s2.blocks)
    println(s2.mode)
    println(s2.uid)
    println(s2.gid)
    println(s2.atim.sec)
    println(s2.atim.nsec)
    println(s2.mtim.sec)
    println(s2.mtim.nsec)
    println(s2.ctim.sec)
    println(s2.ctim.nsec)

    // 不存在的文件
    var s3 = syscall.stat('./asserts/nofound.txt') catch err {
        println(err.msg())
        return
    }
}
